import './assets/main.css'

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import { getSessionStorage } from '@/common'

const app = createApp(App)


//使用路由守卫实现登录的权限验证
router.beforeEach(function (to, from, next) {
    let doctor = getSessionStorage('doctors');
    //除了登录、注册之外，都需要判断是否登录
    if (to.path !== '/'&&  !doctor){

        router.push('/');
}
    next();
    });



app.use(router)

app.use(ElementPlus)
app.use(router)
app.mount('#app')


// //使用路由守卫实现登录的权限验证
// router.beforeEach(function (to, from, next) {
//     let doctor = getSessionStorage('doctors');
//     //除了登录、注册之外，都需要判断是否登录
//     if (to.path !== '/' && !doctor) {

//         router.push('/');

//     }
//     next();
// });

